<?php

class Index extends UI_MobilePage {

    public $url;

    public function __construct() {
	parent::__construct();

	$p = $this->createPage("RSS Reader");

	$p->addHeaderButton(UI_Position::RIGHT, "Add Url", $this->getUrl("examples:rssreader:addUrl"));

	try {

	    $this->fillValues(); // try get values from form

	    if (isset($this->url)) {

		$feed = Zend_Feed::import($this->url);

		$feedList = new UI_ListView();

		foreach ($feed as $entry) {
		    $feedList->add(new UI_ListView_Item($entry->title));
		}

		$p->add($feedList);
	    } else {
		$p->add(new UI_Text("Please adds a URL..."));
	    }
	    
	} catch (Exception $exc) {
	    echo $p->add(new UI_Exception($exc));
	}
    }

}
